<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<c:set var="url" value="${pageContext.request.contextPath}/" />
<link rel="stylesheet" href="${url }plugins/select2/select2.min.css">
<script src="${url }plugins/select2/select2.full.min.js"></script>
<script type="text/javascript">
$(function() {
	init();
});

function init(){
	var addIp =$("#addIp").val();
	$.ajax({
		type:"POST",
		url: path+'collect/getBeatInfo',
		data:{ip:addIp,beatName:'topbeat'},
		success: function(result){
			if(result.result.topbeat.parameter.values.PROCESS){
				$("#processCK").prop("checked",true);
			}else{
				$("#processCK").prop("checked",false);
			}
			
			if(result.result.topbeat.parameter.values.CPU_PER_CORE){
				$("#cpuCK").prop("checked",true);
			}else{
				$("#cpuCK").prop("checked",false);
			}
			
			if(result.result.topbeat.parameter.values.FILESYSTEM){
				$("#fileCK").prop("checked",true);
			}else{
				$("#fileCK").prop("checked",false);
			}
			
			if(result.result.topbeat.parameter.values.SYSTEM){
				$("#systemCK").prop("checked",true);
			}else{
				$("#systemCK").prop("checked",false);
			}
		}
	}); 
}

function addBeat(){
	$.ajax({
		cache:false,
		async:false,
		type:"POST",
		url: path
		+"collect/addTopBeat",
		data:{cpu:$("#cpuCK").prop("checked"),process:$("#processCK").prop("checked"),file:$("#fileCK").prop("checked"),system:$("#systemCK").prop("checked"),ip:$("#addIp").val()},
		success: function(result){
			if(result){
				alert("添加成功");
			}
		}
	});
}
</script>
<div class="box box-info">
	<div class="box-header with-border">
		<h3 class="box-title">FileBeat / </h3>
		<!-- /.box-tools -->
	</div>
<!-- /.box-header -->
  <div class="box-body form-horizontal">
  	<div class="form-group">
       <div class="col-sm-3">
         <input id="cpuCK" type="checkbox" class="flat-red"    />CPU信息
       </div>
     </div>
  	<div class="form-group">
       <div class="col-sm-3">
         <input id="processCK" type="checkbox" class="flat-red"    />进程信息
       </div>
     </div>
  	<div class="form-group">
       <div class="col-sm-3">
         <input  id="fileCK"  type="checkbox" class="flat-red"  />文件系统信息
       </div>
     </div>
  	<div class="form-group">
       <div class="col-sm-3">
         <input id="systemCK" type="checkbox" class="flat-red"  />操作系统信息
       </div>
     </div>
      <div class="box-footer">
        <a type="button" class="btn btn-info" onclick="addBeat()">添加</a>
        <a href="javascript:linkByDom('local-list','${url }collect/getBeatList');" class="btn btn-default">取消</a>
     </div>
  </div>
</div>
	<input type="hidden" value="${ip }" id="addIp" />		            
